package top.purity.server.user.service.impl;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import top.purity.framework.common.UserContextHolder;
import top.purity.server.user.domain.cache.UserCache;
import top.purity.server.user.controller.vo.UserInfoVO;
import top.purity.server.user.domain.User;
import top.purity.server.user.domain.repository.UserRepository;
import top.purity.server.user.service.AccountService;
import top.purity.server.user.service.convert.AccountConvert;
import org.springframework.stereotype.Service;

/**
 * @version 1.0
 * @Author Lmh
 * @Description
 * @CreateTime 2023-09-24 18:52
 */

@Service
@RequiredArgsConstructor
@Slf4j
public class AccountServiceImpl implements AccountService {

    private final UserRepository userRepository;

    private final UserCache userCache;

    @Override
    public UserInfoVO getInfo() {
        Long userId = UserContextHolder.getUserId();
        User user = userRepository.getReferenceById(userId);
        return AccountConvert.INSTANCE.convertToUserInfoVo(user);
    }

}
